<html>
<head><meta charset="utf-8"><title>Not larger than two pointers · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Not.20larger.20than.20two.20pointers.html">Not larger than two pointers</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="232965671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Not%20larger%20than%20two%20pointers/near/232965671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Not.20larger.20than.20two.20pointers.html#232965671">(Apr 02 2021 at 23:58)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="c1">// At least on 64 bit systems, `PlaceElem` should not be larger than two pointers.</span>
<span class="cp">#[cfg(target_arch = </span><span class="s">"x86_64"</span><span class="cp">)]</span><span class="w"></span>
<span class="n">static_assert_size</span><span class="o">!</span><span class="p">(</span><span class="n">PlaceElem</span><span class="o">&lt;'</span><span class="nb">_</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="mi">24</span><span class="p">);</span><span class="w"></span>
</code></pre></div>
<p>Hmm...</p>



<a name="232966113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Not%20larger%20than%20two%20pointers/near/232966113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Not.20larger.20than.20two.20pointers.html#232966113">(Apr 03 2021 at 00:04)</a>:</h4>
<p>4cc2cabee25a looks like it.</p>



<a name="232966236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Not%20larger%20than%20two%20pointers/near/232966236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Not.20larger.20than.20two.20pointers.html#232966236">(Apr 03 2021 at 00:06)</a>:</h4>
<p>Oh, I was just about to propose the reverse of that commit</p>



<a name="232966244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Not%20larger%20than%20two%20pointers/near/232966244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Not.20larger.20than.20two.20pointers.html#232966244">(Apr 03 2021 at 00:06)</a>:</h4>
<p>Surely slice patterns can't have indices that large?</p>



<a name="232966254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Not%20larger%20than%20two%20pointers/near/232966254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Not.20larger.20than.20two.20pointers.html#232966254">(Apr 03 2021 at 00:06)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/75893#issuecomment-680214520">https://github.com/rust-lang/rust/pull/75893#issuecomment-680214520</a></p>



<a name="232966270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Not%20larger%20than%20two%20pointers/near/232966270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Not.20larger.20than.20two.20pointers.html#232966270">(Apr 03 2021 at 00:07)</a>:</h4>
<p>2³² elements seems perfectly reasonable nowadays.</p>



<a name="232966387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Not%20larger%20than%20two%20pointers/near/232966387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Not.20larger.20than.20two.20pointers.html#232966387">(Apr 03 2021 at 00:09)</a>:</h4>
<p>No one seems to have pointed out that in the original bug:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">([(),</span><span class="w"> </span><span class="o">..</span><span class="p">,</span><span class="w"> </span><span class="p">()]</span>: <span class="p">[();</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="mi">40</span><span class="p">])</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>
<p>that should be a <code>1, -1</code> slice pattern instead of <code>1, 1&lt;&lt;40 - 1</code></p>



<a name="232966443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Not%20larger%20than%20two%20pointers/near/232966443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Not.20larger.20than.20two.20pointers.html#232966443">(Apr 03 2021 at 00:10)</a>:</h4>
<p>although it's possible some code is relying on the assumption that arrays never set <code>from_end</code></p>



<a name="232966551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Not%20larger%20than%20two%20pointers/near/232966551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Not.20larger.20than.20two.20pointers.html#232966551">(Apr 03 2021 at 00:12)</a>:</h4>
<p>I actually meant that you would need a 2^32 large source file (or macro expansion) to hit this limit using slice patterns, and I'm pretty sure rustc can't handle files that large</p>



<a name="232966868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Not%20larger%20than%20two%20pointers/near/232966868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Not.20larger.20than.20two.20pointers.html#232966868">(Apr 03 2021 at 00:18)</a>:</h4>
<p>Oh, I guess it's more complicated for <code>ConstantIndex</code>, since the comment says "For arrays is always the exact length", so it wouldn't work for very large arrays if it was a u32. But I guess it could just not be the exact length and just treat array patterns with <code>..</code> the same as slice patterns</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>